/*
 * Filename : ParseContainer.java
 * Description : **COMPLETE**
 * History  : Date               Engineer       Description
 *            ---------          ------------   --------------------------------
 *            September 11, 2007      waitek         Initial creation.
 */

package com.lct.eq2.data;

import java.util.ArrayList;
import java.util.Comparator;

public class ParseContainer implements Comparator {
    private ArrayList dpsParse;
    private ArrayList healParse;
    private StringBuffer zonewideDPSParse;
    private StringBuffer zonewideHealParse;
    private StringBuffer historyDPSParse;
    private StringBuffer historyHealParse;
    
    /**
     * Creates a new instance of ParseContainer
     */
    public ParseContainer() {
        this.dpsParse = new ArrayList();
        this.healParse = new ArrayList();
    }
    
    public StringBuffer getHistoryDPSParse() {
        return this.historyDPSParse;
    }
    
    public StringBuffer getHistoryHealParse() {
        return this.historyHealParse;
    }
    
    public void setHistoryDPSParse(StringBuffer parse) {
        this.historyDPSParse = parse;
    }
    
    public void setHistoryHealParse(StringBuffer parse) {
        this.historyHealParse = parse;
    }
    
    public void setZonewideDPSParse(StringBuffer parse) {
        this.zonewideDPSParse = parse;
    }
    
    public void setZonewideHealParse(StringBuffer parse) {
        this.zonewideHealParse = parse;
    }
    
    public StringBuffer getZonewideDPSParse() {
        return this.zonewideDPSParse;
    }
    
    public StringBuffer getZonewideHealParse() {
        return this.zonewideHealParse;
    }
    
    public ArrayList getHealParse() {
        return this.healParse;
    }
    
    public ArrayList getDPSParse() {
        return this.dpsParse;
    }
    
    public void addToDPSParse(StringBuffer buf) {
        this.dpsParse.add(0, buf);
    }
    
    public void addToHealParse(StringBuffer buf) {
        this.healParse.add(0, buf);
    }
    
    public StringBuffer getDPSParse(int index) {
        return (StringBuffer)this.dpsParse.get(index);
    }
    
    public StringBuffer getHealParse(int index) {
        return (StringBuffer)this.healParse.get(index);
    }
    
    @Override
    public String toString() {
        StringBuffer tmp = new StringBuffer();
        for (int x = 0; x < this.dpsParse.size(); x++) {
            tmp.append(this.dpsParse.get(x) + "\n");
        }
        return tmp.toString();
    }

    public int compare(Object o1, Object o2) {
        String s1 = (String)o1;
        String s2 = (String)o2;
        int rval = 0;
        
        double dps1 = Double.parseDouble(s1.substring(s1.lastIndexOf(" ")).trim());
        double dps2 = Double.parseDouble(s2.substring(s2.lastIndexOf(" ")).trim());
        
        if (dps1 > dps2) {
            rval = -1;
        } else if (dps1 < dps2) {
            rval = 1;
        } else {
            rval = 0;
        }
        return rval;
    }
}
